import { removeToken } from '@/utils/auth'
import { defineStore } from 'pinia'

type UserState = {
  /** 是否登录 */
  isLogin: Boolean
}

const useUserStore = defineStore('user', {
  state: (): UserState => ({
    isLogin: false
  }),
  getters: {

  },
  actions: {
    setIsLogin() {
      this.isLogin = true
    },
    logout() {
      removeToken()
      this.isLogin = false
      location.reload()
    }
  },
})

export default useUserStore